<?php

use mdm\admin\AnimateAsset;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $routes [] */

$this->title = Yii::t('rbac-admin', 'Routes');
$this->params['consoleactions'] = [
    [
        'label' => '<i class="far fa-rss"></i> 更新至菜单',
        'url' => ['push-to-menu'],
        'options' => [
            'id' => 'btn-pushtomenu'
        ],
    ],
    [
        'label' => '<i class="far fa-sd-card"></i> 清理缓存',
        'url' => ['reload'],
    ],
    [
        'label' => '<i class="fal fa-eraser"></i> 清除无效路由',
        'url' => ['filter'],
    ],
];

AnimateAsset::register($this);

$opts = Json::htmlEncode([
    'routes' => $routes,
]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
?>
<div class="row">
    <div class="col-sm-12">
        <div class="input-group">
            <input id="inp-route" type="text" class="form-control" placeholder="<?= Yii::t('rbac-admin', 'New route(s)'); ?>">
            <div class="input-group-append">
                <?=
                Html::a(Yii::t('rbac-admin', 'Add'), ['create'], [
                    'class' => 'btn btn-secondary',
                    'id' => 'btn-new',
                ]);
                ?>
            </div>
        </div>
    </div>
</div>
<p>&nbsp;</p>
<div class="row">
    <div class="col-sm-5">
        <div class="input-icon input-icon-right">
            <input class="form-control search" data-target="available" placeholder="<?= Yii::t('rbac-admin', 'Search for available'); ?>">
            <span data-url="<?= Url::to(['refresh']) ?>" id="btn-refresh">
                <i class="ionicons ion-reload-outline icon-md"></i>
            </span>
        </div>
        <br>
        <select multiple size="20" class="form-control list" data-target="available"></select>
    </div>
    <div class="col-sm-2">
        <br>
        <br>
        <br>
        <div class="text-center">
            <?=
            Html::a('新增', ['assign'], [
                'class' => 'btn btn-success btn-block btn-assign',
                'data-target' => 'available',
                'title' => Yii::t('rbac-admin', 'Assign'),
            ]);
            ?>
            <?=
            Html::a('移除', ['remove'], [
                'class' => 'btn btn-danger btn-block btn-assign',
                'data-target' => 'assigned',
                'title' => Yii::t('rbac-admin', 'Remove'),
            ]);
            ?>
        </div>
    </div>
    <div class="col-sm-5">
        <input class="form-control search" data-target="assigned" placeholder="<?= Yii::t('rbac-admin', 'Search for assigned'); ?>">
        <br>
        <select multiple size="20" class="form-control list" data-target="assigned"></select>
    </div>
</div>
